<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>ButtonGadget</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">ButtonGadget()</font></b></p>
<p><b>语法</b></p><blockquote>

Result = <font color="#3A3966"><b>ButtonGadget</b></font>(#Gadget, x, y, Width, Height, Text$ [, Flags])</blockquote>

</blockquote>
<b>概要</b><br><blockquote>



Create a button gadget in the current GadgetList. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Gadget</i></td>
<td width="90%"> 
A number to identify the new gadget. <a href="../reference/purebasic_objects.html">#PB_Any</a> 可以用来自动生成这个编码. 

</td></tr>
<tr><td><i>x, y, Width, Height</i></td>
<td> 
 
The position and dimensions of the new gadget. 
<b>Note</b>: on OS X, using an height of 25 will enable the fixed height button type, which is 
commonly used in OS X applications. It will also make the <font color="#924B72">#PB_Button_Default</font> flags available. 

 

</td></tr>
<tr><td><i>Text$</i></td>
<td> 
 
The text to display on the button. 

 

</td></tr>
<tr><td><i>Flags (可选)</i></td>
<td> 
 
A combination (using the bitwise OR operator '|') of the following constants: 
 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Button_Right</font>     : Aligns the button text at the right. (not supported on Mac OSX)
  <font color="#924B72">#PB_Button_Left</font>      : Aligns the button text at the left. (not supported on Mac OSX)
  <font color="#924B72">#PB_Button_Default</font>   : Makes the button look as if it is the default button in the window (on OS X, the height of the button needs to be 25).
  <font color="#924B72">#PB_Button_MultiLine</font> : If the text is too long, it will be displayed on several lines. (not supported on Mac OSX)
  <font color="#924B72">#PB_Button_Toggle</font>    : Creates a toggle button: one click pushes it, another will release it.
</font></pre>

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>



Returns nonzero on success and zero on failure. If <font color="#924B72">#PB_Any</font> was used as the #Gadget parameter 
then the return-value is the auto-generated gadget number on success. 

 

</blockquote><p><b>备注</b></p><blockquote>



A 'mini help' can be added to this gadget using <a href="gadgettooltip.html">GadgetToolTip()</a>. 
<br>
<br>
The following functions can be used to control the gadget: 
<br>
<br>
- <a href="setgadgettext.html">SetGadgetText()</a>: Changes the text of the ButtonGadget. 
<br>
- <a href="getgadgettext.html">GetGadgetText()</a>: Returns the text of the ButtonGadget. 
<br>
- <a href="setgadgetstate.html">SetGadgetState()</a>: Used with <font color="#924B72">#PB_Button_Toggle</font> buttons to set the actual state (1 = toggled, 0 = normal). 
<br>
- <a href="getgadgetstate.html">GetGadgetState()</a>: Used with <font color="#924B72">#PB_Button_Toggle</font> buttons to get the actual state of the button (1 = toggled, 0 = normal). 


 


</blockquote><p><b>示例</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#3A3966">; Shows possible flags of ButtonGadget in action...</font>
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 222, 200, "ButtonGadgets", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
<font color="#3A3966">    ButtonGadget</font>(0, 10, 10, 200, 20, "Standard Button")
<font color="#3A3966">    ButtonGadget</font>(1, 10, 40, 200, 20, "Left Button", <font color="#924B72">#PB_Button_Left</font>)
<font color="#3A3966">    ButtonGadget</font>(2, 10, 70, 200, 20, "Right Button", <font color="#924B72">#PB_Button_Right</font>)
<font color="#3A3966">    ButtonGadget</font>(3, 10,100, 200, 60, "Multiline Button  (longer text gets automatically wrapped)", <font color="#924B72">#PB_Button_MultiLine</font>)
<font color="#3A3966">    ButtonGadget</font>(4, 10,170, 200, 20, "Toggle Button", <font color="#924B72">#PB_Button_Toggle</font>)
    <b><font color="#3A3966">Repeat</font></b> : <b><font color="#3A3966">Until</font></b> <font color="#3A3966">WaitWindowEvent</font>() = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>
<br>
<p><img src="../HelpPictures/buttongadget.png"></p>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="setgadgettext.html">SetGadgetText()</a>, <a href="getgadgettext.html">GetGadgetText()</a>, <a href="setgadgetstate.html">SetGadgetState()</a>, <a href="getgadgetstate.html">GetGadgetState()</a>, <a href="buttonimagegadget.html">ButtonImageGadget()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center>&lt;- <a href=bindgadgetevent.html>BindGadgetEvent()</a> - <a href="index.html">Gadget Index</a> - <a href="buttonimagegadget.html">ButtonImageGadget()</a> -&gt;<br><br>

</body></html>